<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input v-model="crud.queryInput.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="crud.queryInput.type" clearable placeholder="类型" class="filter-item" style="width: 130px">
          <el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="560px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="140px">
          <el-collapse v-model="activeNames" accordion>
            <el-collapse-item title="基础信息填报" name="1">
              <el-form-item v-if="false" label="ID">
                <el-input v-model="form.id" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题发生舰船">
                <el-input v-model="form.ship" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题舰艇型号">
                <el-select v-model="form.shipType" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.ship_type"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="问题发生项目-阶段" prop="projectId">
                <project-stage-select :value="[form.projectId,form.projectStage]" style="width: 370px;" @input="stageSelectInput" />
              </el-form-item>
              <el-form-item label="问题软件标识">
                <el-input v-model="form.issueSoftId" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题软件版本号">
                <el-input v-model="form.issueSoftVersion" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题名称" prop="issueName">
                <el-input v-model="form.issueName" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题描述" prop="issueDesc">
                <el-input v-model="form.issueDesc" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题意见答复">
                <el-select v-model="form.issueReply" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_reply"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="问题种类" prop="issueType">
                <el-select v-model="form.issueType" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_type"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="严重程度" prop="issueSeverity">
                <el-select v-model="form.issueSeverity" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_severity"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="问题优先级" prop="priorityLevel">
                <el-select v-model="form.priorityLevel" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.priority"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="通报时间">
                <el-date-picker v-model="form.avisoTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="通报机关">
                <el-input v-model="form.avisoName" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题平台" prop="issuePlat">
                <el-select v-model="form.issuePlat" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_plat"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="质量问题来源" prop="issueSourceType">
                <el-select v-model="form.issueSourceType" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_source_type"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="质量问题来源地" prop="issueSourceLocate">
                <el-select v-model="form.issueSourceLocate" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_source_locate"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="问题分析">
                <el-input v-model="form.analyse" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题性质" prop="issueQuality">
                <el-select v-model="form.issueQuality" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_quality"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="问题发现人">
                <el-input v-model="form.issueFinderId" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题发现时间">
                <el-date-picker v-model="form.issueDiscoveryTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="计划完成时间">
                <el-date-picker v-model="form.planFinishTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="实际解决时间">
                <el-date-picker v-model="form.issueFinishTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="处理完成状态">
                <el-select v-model="form.issueFinishState" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_finish_state"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="项目组信息填报" name="2">
              <el-form-item label="问题所属功能域">
                <el-select v-model="form.issueFunctionArea" filterable placeholder="请选择" style="width: 370px;">
                  <el-option
                    v-for="item in dict.issue_function_area"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="完成情况说明">
                <el-input v-model="form.issueFinishRemark" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="项目组提出问题时间">
                <el-date-picker v-model="form.projectTeamRaiseQuestionsTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="项目组要求完成时间">
                <el-date-picker v-model="form.projectTeamRequireFinishTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="项目组确定需求时间">
                <el-date-picker v-model="form.projectTeamConfirmDemandTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="需求是否明确">
                <el-radio-group v-model="form.isDemandClear" style="width: 178px">
                  <el-radio label="是">是</el-radio>
                  <el-radio label="否">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="项目组问题修改建议">
                <el-input v-model="form.projectTeamSuggest" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="功能域子模块名称">
                <el-input v-model="form.moduleName" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="域负责人">
                <el-input v-model="form.domainHeadPerson" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题确认情况">
                <el-input v-model="form.issueComfirmType" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="反馈意见">
                <el-input v-model="form.feedback" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题分析及解决措施">
                <el-input v-model="form.analyseSolutions" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="问题修改情况">
                <el-input v-model="form.modification" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="是否发布">
                <el-input v-model="form.isRelease" style="width: 370px;" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="集成验证填报" name="3">
              <el-form-item label="集成情况">
                <el-input v-model="form.integration" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="验证情况">
                <el-input v-model="form.verification" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="集成验证情况">
                <el-input v-model="form.integrationVerification" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="测试填报" name="4">
              <el-form-item label="测试方">
                <el-input v-model="form.testTeam" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="测试人员">
                <el-input v-model="form.testers" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="测试时间">
                <el-date-picker v-model="form.testTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="测试项标志">
                <el-input v-model="form.testMark" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="被测试问题类别">
                <el-input v-model="form.testType" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="测试情况说明">
                <el-input v-model="form.testDescribe" type="textarea" :rows="3" style="width: 370px;" />
              </el-form-item>
            </el-collapse-item>
            <el-collapse-item title="归零信息填报" name="5">
              <el-form-item label="问题归零完成状态">
                <el-input v-model="form.zeroState" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="质量问题通报时间">
                <el-date-picker v-model="form.zeroTime" type="datetime" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="质量处问题库问题">
                <el-radio-group v-model="form.inQualityLibrary" style="width: 178px">
                  <el-radio label="是">是</el-radio>
                  <el-radio label="否">否</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item label="处理后软件版本">
                <el-input v-model="form.afterEdition" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="所属变更申请单号">
                <el-input v-model="form.changeNum" style="width: 370px;" />
              </el-form-item>
              <el-form-item label="所属入库申请单号">
                <el-input v-model="form.inStorageNum" style="width: 370px;" />
              </el-form-item>
            </el-collapse-item>
          </el-collapse>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        style="width: 100%;"
        :row-class-name="rowClassSequenceNo"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column v-if="columns.visible('sequence')" prop="sequence" label="序号" width="60" />
        <el-table-column v-if="columns.visible('ship')" prop="ship" label="问题发生舰船" width="120" />
        <el-table-column v-if="columns.visible('shipType')" prop="shipType" label="问题舰艇型号" width="120">
          <template slot-scope="scope">
            {{ dict.label.ship_type[scope.row.shipType] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('projectId')" prop="projectStage.projectBase.projectName" label="问题发生项目" width="120" />
        <el-table-column v-if="columns.visible('projectStage')" prop="projectStage.stageName" label="问题发生阶段" width="120" />
        <el-table-column v-if="columns.visible('issueSoftId')" prop="issueSoftId" label="问题软件标识" width="120" />
        <el-table-column v-if="columns.visible('issueSoftVersion')" prop="issueSoftVersion" label="问题软件版本号" width="120" />
        <el-table-column v-if="columns.visible('issueName')" prop="issueName" label="问题名称" />
        <el-table-column v-if="columns.visible('issueDesc')" prop="issueDesc" label="问题描述" width="300" />
        <el-table-column v-if="columns.visible('issueReply')" prop="issueReply" label="问题意见答复" width="120">
          <template slot-scope="scope">
            {{ dict.label.issue_reply[scope.row.issueReply] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueType')" prop="issueType" label="问题种类">
          <template slot-scope="scope">
            {{ dict.label.issue_type[scope.row.issueType] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueSeverity')" prop="issueSeverity" label="严重程度">
          <template slot-scope="scope">
            {{ dict.label.issue_severity[scope.row.issueSeverity] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('priorityLevel')" prop="priorityLevel" label="问题优先级">
          <template slot-scope="scope">
            {{ dict.label.priority[scope.row.priorityLevel] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('avisoTime')" prop="avisoTime" label="通报时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.avisoTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('avisoName')" prop="avisoName" label="通报机关" />
        <el-table-column v-if="columns.visible('issuePlat')" prop="issuePlat" label="问题平台">
          <template slot-scope="scope">
            {{ dict.label.issue_plat[scope.row.issuePlat] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueSourceType')" prop="issueSourceType" label="质量问题来源" width="120">
          <template slot-scope="scope">
            {{ dict.label.issue_source_type[scope.row.issueSourceType] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueSourceLocate')" prop="issueSourceLocate" label="质量问题来源地" width="140">
          <template slot-scope="scope">
            {{ dict.label.issue_source_locate[scope.row.issueSourceLocate] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('analyse')" prop="analyse" label="问题分析" />
        <el-table-column v-if="columns.visible('issueQuality')" prop="issueQuality" label="问题性质">
          <template slot-scope="scope">
            {{ dict.label.issue_quality[scope.row.issueQuality] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueFinderId')" prop="issueFinderId" label="问题发现人" />
        <el-table-column v-if="columns.visible('issueDiscoveryTime')" prop="issueDiscoveryTime" label="问题发现时间" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.issueDiscoveryTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('planFinishTime')" prop="planFinishTime" label="计划完成时间" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.planFinishTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueFinishTime')" prop="issueFinishTime" label="实际解决时间" width="120">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.issueFinishTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueFinishState')" prop="issueFinishState" label="处理完成状态" width="120">
          <template slot-scope="scope">
            {{ dict.label.issue_finish_state[scope.row.issueFinishState] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueFunctionArea')" prop="issueFunctionArea" label="问题所属功能域" width="120">
          <template slot-scope="scope">
            {{ dict.label.issue_function_area[scope.row.issueFunctionArea] }}
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('issueFinishRemark')" prop="issueFinishRemark" label="完成情况说明" />
        <el-table-column v-if="columns.visible('projectTeamRaiseQuestionsTime')" prop="projectTeamRaiseQuestionsTime" label="项目组提出问题时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.projectTeamRaiseQuestionsTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('projectTeamRequireFinishTime')" prop="projectTeamRequireFinishTime" label="项目组要求完成时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.projectTeamRequireFinishTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('projectTeamConfirmDemandTime')" prop="projectTeamConfirmDemandTime" label="项目组确定需求时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.projectTeamConfirmDemandTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('isDemandClear')" prop="isDemandClear" label="需求是否明确" />
        <el-table-column v-if="columns.visible('projectTeamSuggest')" prop="projectTeamSuggest" label="项目组问题修改建议" />
        <el-table-column v-if="columns.visible('moduleName')" prop="moduleName" label="功能域子模块名称" />
        <el-table-column v-if="columns.visible('domainHeadPerson')" prop="domainHeadPerson" label="域负责人" />
        <el-table-column v-if="columns.visible('issueComfirmType')" prop="issueComfirmType" label="问题确认情况" />
        <el-table-column v-if="columns.visible('feedback')" prop="feedback" label="反馈意见" />
        <el-table-column v-if="columns.visible('analyseSolutions')" prop="analyseSolutions" label="问题分析及解决措施" />
        <el-table-column v-if="columns.visible('modification')" prop="modification" label="问题修改情况" />
        <el-table-column v-if="columns.visible('isRelease')" prop="isRelease" label="是否发布" />
        <el-table-column v-if="columns.visible('integration')" prop="integration" label="集成情况" />
        <el-table-column v-if="columns.visible('verification')" prop="verification" label="验证情况" />
        <el-table-column v-if="columns.visible('integrationVerification')" prop="integrationVerification" label="集成验证情况" />
        <el-table-column v-if="columns.visible('testTeam')" prop="testTeam" label="测试方" />
        <el-table-column v-if="columns.visible('testers')" prop="testers" label="测试人员" />
        <el-table-column v-if="columns.visible('testTime')" prop="testTime" label="测试时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.testTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('testMark')" prop="testMark" label="测试项标志" />
        <el-table-column v-if="columns.visible('testType')" prop="testType" label="被测试问题类别" />
        <el-table-column v-if="columns.visible('testDescribe')" prop="testDescribe" label="测试情况说明" />
        <el-table-column v-if="columns.visible('zeroState')" prop="zeroState" label="问题归零完成状态" />
        <el-table-column v-if="columns.visible('zeroTime')" prop="zeroTime" label="质量问题通报时间">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.zeroTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column v-if="columns.visible('inQualityLibrary')" prop="inQualityLibrary" label="是否质量处问题库问题" />
        <el-table-column v-if="columns.visible('afterEdition')" prop="afterEdition" label="处理后软件版本" />
        <el-table-column v-if="columns.visible('changeNum')" prop="changeNum" label="问题所属变更申请单号" />
        <el-table-column v-if="columns.visible('inStorageNum')" prop="inStorageNum" label="问题所入库申请单号" />
        <el-table-column v-permission="['admin','projectIssue:edit','projectIssue:del']" fixed="right" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudProjectIssue from '@/api/projectIssue'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import projectStageSelect from '@/views/components/cascader/project_stage_cascader'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '项目问题', url: 'api/projectIssue', sort: 'id,desc', crudMethod: { ...crudProjectIssue }})
const defaultForm = { id: null, ship: null, shipType: null, projectId: null, projectStage: null, issueSoftId: null, issueSoftVersion: null, issueName: null, issueDesc: null, issueReply: null, issueType: null, issueSeverity: null, priorityLevel: null, avisoTime: null, avisoName: null, issuePlat: null, issueSourceType: null, issueSourceLocate: null, analyse: null, issueQuality: null, issueFinderId: null, issueDiscoveryTime: null, planFinishTime: null, issueFinishTime: null, issueFinishState: null, issueFunctionArea: null, issueFinishRemark: null, projectTeamRaiseQuestionsTime: null, projectTeamRequireFinishTime: null, projectTeamConfirmDemandTime: null, isDemandClear: null, projectTeamSuggest: null, moduleName: null, domainHeadPerson: null, issueComfirmType: null, feedback: null, analyseSolutions: null, modification: null, isRelease: null, integration: null, verification: null, integrationVerification: null, testTeam: null, testers: null, testTime: null, testMark: null, testType: null, testDescribe: null, zeroState: null, zeroTime: null, inQualityLibrary: null, afterEdition: null, changeNum: null, inStorageNum: null }
export default {
  name: 'ProjectIssue',
  components: { pagination, crudOperation, rrOperation, udOperation, projectStageSelect },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  dicts: ['ship_type', 'issue_reply', 'issue_type', 'issue_severity', 'priority', 'issue_plat', 'issue_source_type', 'issue_quality', 'issue_finish_state', 'issue_function_area', 'issue_source_locate'],
  data() {
    return {
      activeNames: ['1'],
      permission: {
        add: ['admin', 'projectIssue:add'],
        edit: ['admin', 'projectIssue:edit'],
        del: ['admin', 'projectIssue:del']
      },
      rules: {
        projectId: [
          { required: true, message: '问题发生项目-阶段不能为空', trigger: 'blur' }
        ],
        issueName: [
          { required: true, message: '问题名称不能为空', trigger: 'blur' }
        ],
        issueDesc: [
          { required: true, message: '问题描述不能为空', trigger: 'blur' }
        ],
        issueType: [
          { required: true, message: '问题种类不能为空', trigger: 'blur' }
        ],
        issueSeverity: [
          { required: true, message: '严重程度不能为空', trigger: 'blur' }
        ],
        priorityLevel: [
          { required: true, message: '问题优先级不能为空', trigger: 'blur' }
        ],
        issuePlat: [
          { required: true, message: '问题平台不能为空', trigger: 'blur' }
        ],
        issueSourceType: [
          { required: true, message: '质量问题来源不能为空', trigger: 'blur' }
        ],
        issueQuality: [
          { required: true, message: '问题性质不能为空', trigger: 'blur' }
        ]
      },
      queryTypeOptions: [
        { key: 'ship', display_name: '问题发生舰船' },
        { key: 'shipType', display_name: '问题舰艇型号' },
        { key: 'projectName', display_name: '问题发生项目' },
        { key: 'projectStageName', display_name: '问题发生阶段' },
        { key: 'issueName', display_name: '问题名称' },
        { key: 'issueDesc', display_name: '问题描述' },
        { key: 'issueReply', display_name: '问题意见答复' },
        { key: 'issueType', display_name: '问题种类' },
        { key: 'issueSeverity', display_name: '严重程度' },
        { key: 'priorityLevel', display_name: '问题优先级' },
        { key: 'avisoTime', display_name: '通报时间' },
        { key: 'avisoName', display_name: '通报机关' },
        { key: 'issuePlat', display_name: '问题平台' },
        { key: 'issueSourceType', display_name: '质量问题来源' },
        { key: 'issueSourceLocate', display_name: '质量问题来源地' },
        { key: 'issueQuality', display_name: '问题性质' },
        { key: 'issueDiscoveryTime', display_name: '问题发现时间' },
        { key: 'planFinishTime', display_name: '计划完成时间' },
        { key: 'issueFinishTime', display_name: '实际解决时间' },
        { key: 'issueFinishState', display_name: '处理完成状态' },
        { key: 'issueFunctionArea', display_name: '问题所属功能域' },
        { key: 'issueSoftId', display_name: '问题软件标识' },
        { key: 'issueSoftVersion', display_name: '问题软件版本号' },
        { key: 'projectId', display_name: '问题发生项目ID' },
        { key: 'projectStage', display_name: '问题发生阶段ID' },
        { key: 'id', display_name: 'ID' }
      ],
      pageCount: 0
    }
  },
  mounted() {
    // 默认隐藏
    for (const key in this.crud.props.tableColumns) {
      this.crud.props.tableColumns[key].visible = false
    }
    this.crud.props.tableColumns.sequence.visible = true
    this.crud.props.tableColumns.ship.visible = true
    this.crud.props.tableColumns.shipType.visible = true
    this.crud.props.tableColumns['projectStage.stageName'].visible = true
    this.crud.props.tableColumns['projectStage.projectBase.projectName'].visible = true
    this.crud.props.tableColumns.issueType.visible = true
    this.crud.props.tableColumns.issueSeverity.visible = true
    this.crud.props.tableColumns.issueReply.visible = true
    this.crud.props.tableColumns.priorityLevel.visible = true
    this.crud.props.tableColumns.issueSourceType.visible = true
    this.crud.props.tableColumns.issueSourceLocate.visible = true
    this.crud.props.tableColumns.issueQuality.visible = true
    this.crud.props.tableColumns.issueDiscoveryTime.visible = true
    this.crud.props.tableColumns.planFinishTime.visible = true
    this.crud.props.tableColumns.issueFinishState.visible = true
  },
  created() {
    // 设置默认搜索条件
    if (this.$route.query.mode === 'ONE') {
      // console.log('one')
      this.formDefaultValue.projectId = this.$route.query.projectId
      this.formDefaultValue.projectName = this.$route.query.projectName
      this.formDefaultValue.projectStage = this.$route.query.stageId
      this.formDefaultValue.stageName = this.$route.query.stageName
      // console.log(this.formDefaultValue)
      this.crud.queryInput.type = 'projectStageId'
      this.crud.queryInput.value = this.$route.query.stageId
    }
    // 注意这里需要手动refreash加载数据，如果crud自动加载数据，则无法保证设置query发生在refreah之前
    // this.crud.refresh()
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      if (this.pageCount === 0) {
        if (this.$route.query.mode === 'ONE') {
          this.crud.queryInput.type = 'projectStageId'
          this.crud.queryInput.value = this.$route.query.stageId
        }
        this.pageCount = this.pageCount + 1
      }
      if (this.crud.queryInput.type && this.crud.queryInput.value) {
        this.crud.query[this.queryInput.type] = this.queryInput.value
      }
      return true
    },
    rowClassSequenceNo({ row, rowIndex }) {
      // 把每一行的索引放进row.id
      row.sequence = rowIndex + 1
    },
    stageSelectInput(e) {
      this.form.projectId = e[0]
      this.form.projectStage = e[1]
    }
  }
}
</script>

<style scoped>

</style>
